package com.mk.carcassonne.drawables;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;

import com.mk.carcassonne.FollowerPlacement;
import com.mk.carcassonne.Global;
import com.mk.carcassonne.Position;
import com.mk.carcassonne.R;

public class Follower implements Drawable{
	
	private Brick _brick;
	private FollowerPlacement _followerPlacement;
	
	public Follower(Brick brick, FollowerPlacement followerPlacement)
	{
		_brick = brick;
		_followerPlacement = followerPlacement;
	}

	@Override
	public void draw(Context context, Canvas canvas, Position shift) {

		Position rotatatedPosition = _followerPlacement.getRotatatedPosition(_brick.getRotation());
		int x = shift.getX() + _brick.getPosition().getX() * Global.BRICK_SIZE + (int)(rotatatedPosition.getX() * Global.BRICK_SIZE / 100.0) - Global.FOLLOWER_SIZE / 2;
		int y = shift.getY() + _brick.getPosition().getY() * Global.BRICK_SIZE + (int)(rotatatedPosition.getY() * Global.BRICK_SIZE / 100.0) - Global.FOLLOWER_SIZE / 2;
		
		Matrix m = new Matrix();
		m.postTranslate(x, y);
		
		canvas.drawBitmap(Global.BitmapRepository.getBitmapForResource(R.drawable.follower_red), m, null);
	}
}
